{extend name="public/world"}
{block name="title"}添加科目{/block}
{block name="style"}
<style type="text/css">
    .layui-form-label {width:110px;}
</style>
{/block}
{block name="container"}
<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
    <div class="layui-card" style="padding: 20px 0 0 0;height:495px;">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label label-required">上级科目</label>
                <div class="layui-input-inline" style="width: 300px;">
                    <input type="text" name="tree_name" id="tree_name" lay-filter="tree_name"  value="" lay-verify="required" placeholder="请选择上级科目" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="LAY-front-submit" id="LAY-front-submit" value="确认">
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    //JavaScript代码区域
    layui.use(['form', 'treeSelect'], function() {
        var $ = layui.$
            , treeSelect = layui.treeSelect
            , form = layui.form;
        treeSelect.render({
            // 选择器
            elem: '#tree_name',
            // 数据
            data: "{:url('/erp.BasicsSubject/add')}?op=getTree&id={$id}",
            // 异步加载方式：get/post，默认get
            type: 'post',
            // 占位符
            placeholder: '请选择上级科目',
            // 是否开启搜索功能：true/false，默认false
            search: true,
            // 点击回调
            click: function(d){
                console.log(d);
            },
            // 加载完成后的回调函数
            success: function (d) {
                //console.log(d);
                // 选中节点，根据id筛选
                treeSelect.checkNode('tree_name', {$id});

                //获取zTree对象，可以调用zTree方法
                // var treeObj = treeSelect.zTree('tree');
                // console.log(treeObj);
                // 刷新树结构
                // treeSelect.refresh();
            }
        });
    });
</script>
{/block}